package com.ehome.poct.base.device.service;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.ehome.core.service.AbstractCrudServiceImpl;
import com.ehome.poct.base.api.dto.device.BootInfoExportQry;
import com.ehome.poct.base.api.dto.device.BootingExportQry;
import com.ehome.poct.base.api.dto.device.bootModule.TestDeviceBootInfoDTO;
import com.ehome.poct.base.api.dto.device.bootModule.TestDeviceBootingDetailDTO;
import com.ehome.poct.base.api.virtual.device.TestDeviceBootingDetailService;
import com.ehome.poct.base.api.vo.device.BootDetailExportVO;
import com.ehome.poct.base.device.repository.TestDeviceBootingDetailRepository;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 开机自检记录详细SerivceImlp
 *
 * @author laobai
 * @Date 2022-10-17 10:11
 */
@Service
public class TestDeviceBootingDetailServiceImpl extends AbstractCrudServiceImpl<TestDeviceBootingDetailDTO> implements TestDeviceBootingDetailService {
    @Autowired
    TestDeviceBootingDetailRepository bootingDetailRepository;

    /**
     *获取设备的开机自检详细信息
     * @param qry 多个设备
     * @return 开机自检详细信息
     */
    @Override
    public List<TestDeviceBootingDetailDTO> getExportDetailData(BootInfoExportQry qry) {

        return  bootingDetailRepository.list(Optional.ofNullable(qry.getSno()).map(i -> { Map<String, Object> map = Maps.newHashMap(); map.put("sno",List.of(i.split(",")));return map; }).orElse(Maps.newHashMap()));
    }
}